<?php
use yii\helpers\Html;
use common\components\widgets\Datetimepicker;
use common\components\helpers\Fun;
Datetimepicker::widget();
?>
<div class="yx-praise-list-box yx-praise-box yx-radius2 zx-min-height">
    <?= $this->renderFile('@zhtfrontend/views/layouts/toolbar.php'); ?>
    <div id="search-area" class="yx-bgf7f7f7 yx-radius5 zx-mg yx-function2 yx-pr0">
        <?= Html::beginForm(Fun::url(['subscribe/index']), 'get', ['enctype' => 'multipart/form-data']) ?>
        <?= \common\components\helpers\Search::textInput('nickname', null, ['label'=>'昵称','class' => 'search yx-width150 zx-lh24 yx-ml6']); ?>
        <?= \common\components\helpers\Search::textInput('searchDate', null, ['label'=>'关注日期','class' => 'search datetimepicker yx-width150 zx-lh24 yx-ml6']); ?>
        <?=\common\components\helpers\Search::dropDownList('is_subscribe',null,[null=>'请选择',1=>'已关注',2=>'取消关注'],['label'=>'状态','promote'=>'请选择','class'=>'search diy_select_txt'])?>
        <?= \common\components\helpers\Search::submitButton('搜索', ['id'=>'search-handle','class'=>"yx-search yx-radius2"]); ?>
        <?php Html::endForm() ?>
    </div>

    <div class="docs-main zx-mg">
            <table id="tablesaw" class="tablesaw table yx-table1 yx-table3 table-striped with-check" >
                <thead>
                <tr class="yx-bgd2f6ec">
                    <th><?=\Yii::t('zhtfrontend','ID');?></th>
                    <th><?=\Yii::t('zhtfrontend','昵称');?></th>
                    <th><?=\Yii::t('zhtfrontend','性别');?></th>
                    <th><?=\Yii::t('zhtfrontend','省');?></th>
                    <th><?=\Yii::t('zhtfrontend','市');?></th>
                    <th><?=\Yii::t('zhtfrontend','关注时间');?></th>
                    <th><?=\Yii::t('zhtfrontend','状态');?></th>
                    <th><?=\Yii::t('zhtfrontend','修改时间');?></th>
                    <th><?=\Yii::t('zhtfrontend','备注');?></th>
                    <th><?=\Yii::t('zhtfrontend','是否注册');?></th>
                    <th><?=\Yii::t('zhtfrontend','是否是用户');?></th>
                </tr>
               </thead>
                <?php if($data):?>
                    <?php foreach($data as $item):?>
                        <tr data-id="<?=$item['id']?>">
                            <td><?=$item['id']?></td>
                            <td><?=$item['nickname']?></td>
                            <td><?=$item['sex']?></td>
                            <td><?=$item['province']?></td>
                            <td><?=$item['city']?></td>
                            <td><?=$item['subscribe_time']?></td>
                            <td><?=$item['is_subscribe']?></td>
                            <td><?=$item['updated_at']?></td>
                            <td><?=$item['remark']?></td>
                            <td><?=$item['is_register']?></td>
                            <td><?=$item['operate']?></td>
                        </tr>
                    <?php endforeach;?>
                <?php endif;?>
        </table>
        <div style="text-align: right"><?= common\components\widgets\GoPager::widget(['pagination' => $pages]) ?></div>
    </div>
</div>
<input type="hidden" data-url="<?=\common\components\helpers\Fun::url('subscribe/transfergroup')?>" id="url" >

<?php
$js = <<<JS
   $(document).on('change','input[type="checkbox"]',function(){
       var groupid = 2;
       var _this = $(this);
       var url = $('#url').data('url');
       var id = _this.val();
        if($(this).is(':checked')){
           groupid = 101;
        }
       $.post(url, {id:id,groupid:groupid,_csrf:yii.getCsrfToken()}, function (data) {
            if(data.data == 1){
            }else{
             alert(data.content);
            }
        }, 'json');
   });
JS;
$this->registerJS($js);
?>

